home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 25 / CU Amiga Magazine's Super CD-ROM 25 (1998)(EMAP Images)(GB)(Track 1 of 2)[!][issue 1998-08].iso / CUCD / Magazine / C_Tutorial / Part-11 / req1 / drawwin.c < prev    next >
C/C++ Source or Header  |  1998-04-05  |  2KB  |  78 lines

  1. #include "drawwin.h"
  2. #include "bitmap.h"
  3. #include "gadgets.h"
  4. #include "menu.h"
  5. #include "screen.h"
  6.  
  7. #include<graphics/rastport.h>
  8.  
  9. #include<stdio.h>
  10.  
  11. #include<clib/graphics_protos.h>
  12. #include<clib/intuition_protos.h>
  13.  
  14. /* Global record of our tool window */
  15. struct Window* drawwin = NULL;
  16.  
  17. int openDrawWin()
  18. {
  19.     struct Screen* scr = getScreen();
  20.     setModified(FALSE);
  21.     /* Open our drawing window */
  22.     if(drawwin = OpenWindowTags(NULL,
  23.                                                             WA_Left,                    0,
  24.                                                             WA_Top,                        0,
  25.                                                             /* Make the window the same size as the screen */
  26.                                                             WA_Width,                    scr->Width,
  27.                                                             WA_Height,                scr->Height,
  28.                                                             WA_Flags,                    WFLG_BACKDROP | WFLG_BORDERLESS | WFLG_REPORTMOUSE | WFLG_SUPER_BITMAP,
  29.                                                             WA_IDCMP,                    IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_MENUPICK,
  30.                                                             WA_CustomScreen,    scr,
  31.                                                             WA_SuperBitMap,        getBitmap(),
  32.                                                             TAG_DONE,                    0))
  33.     {
  34.         /* Clear our window, since our new bitmap may not be cleared already */
  35.         SetRast(drawwin->RPort, 0);
  36.         /* Set the drawing mode to draw only the foreground of text, not the background */
  37.         SetDrMd(drawwin->RPort, JAM1);
  38.         resetFgPen(drawwin);
  39.         /* Attach menu strip to drawing window */
  40.         if(SetMenuStrip(drawwin, getMenuStrip()))
  41.             return TRUE;
  42.         else
  43.             printf("Error: could not attach menus to drawing window\n");
  44.     }
  45.     else
  46.         printf("Error: could not open drawing window\n");
  47.     return FALSE;
  48. }
  49.  
  50. void closeDrawWin()
  51. {
  52.     if(drawwin)
  53.     {
  54.         ClearMenuStrip(drawwin);
  55.         CloseWindow(drawwin);
  56.         drawwin = NULL;
  57.     }
  58. }
  59.  
  60. struct Window* getDrawWin()
  61. {
  62.     return drawwin;
  63. }
  64.  
  65. /* Record of whether the image has changed */
  66. static int modified = FALSE;
  67.  
  68. int isModified()
  69. {
  70.     return modified;
  71. }
  72.  
  73. void setModified(int mod)
  74. {
  75.     modified = mod;
  76. }
  77.  
  78.